home *** CD-ROM | disk | FTP | other *** search
/ JCSM Shareware Collection 1993 November / JCSM Shareware Collection - 1993-11.iso / cl720 / qbnws31j.lzh / SLBOX.ASM < prev    next >
Assembly Source File  |  1991-11-07  |  3KB  |  166 lines

  1. PAGE 56,132
  2. TITLE SLBox.ASM - QBasic bin file for Single Line boxes 
  3. ;
  4. ; SLBox.ASM - (C)1991 by Brent Ashley
  5. ; draws single line box - called from QBasic 
  6. ; Parameters: Top, Left, Bot, Rgt, Attr, Shad
  7. ; Returns: nothing
  8. ;
  9. ; written with Microsoft QC/QuickAssembler v2.51
  10. ;
  11.  
  12. ; equates for box characters
  13. ULC = 218
  14. URC = 191
  15. LLC = 192
  16. LRC = 217
  17. HOR = 196
  18. VER = 179
  19. SPC = 32
  20.  
  21. ; macros
  22. LoadParmB MACRO Parm,Dest
  23.   mov bx,Parm
  24.   mov al,[bx]
  25.   mov Dest,al
  26. ENDM
  27.  
  28. SetCur MACRO Row,Col
  29.   ; set cursor position
  30.   push dx
  31.   mov ah,02
  32.   sub bh,bh
  33.   mov dh,Row
  34.   mov dl,Col
  35.   int 10h
  36.   pop dx
  37. ENDM
  38.  
  39. PutChar MACRO Row,Col,Char,Colr,Count
  40.   SetCur Row,Col
  41.   ; print char using BIOS
  42.   mov ah,09h
  43.   mov al,Char
  44.   sub bh,bh
  45.   mov bl,Colr
  46.   xor cx,cx
  47.   mov cl,Count
  48.   int 10h
  49. ENDM
  50.  
  51. ShadowChar MACRO
  52.   ; get current char
  53.   mov ah,08
  54.   sub bh,bh
  55.   int 10h
  56.   ; rewrite it in shadow colour
  57.   mov ah,09h
  58.   mov bx,0008h
  59.   mov cx,1
  60.   int 10h
  61. ENDM
  62.  
  63. ; procedure
  64. .MODEL  medium, BASIC
  65. .CODE
  66.  
  67. SLBox  PROC  _Top:PTR BYTE, _Lft:PTR BYTE, \
  68.              _Bot:PTR BYTE, _Rgt:PTR BYTE, \
  69.              _Attr:PTR BYTE, _Shad:PTR BYTE
  70.  
  71. Local Wid:BYTE, Mid:BYTE, \
  72.       Top:BYTE, Lft:BYTE, \
  73.       Bot:BYTE, Rgt:BYTE, \
  74.       Attr:BYTE, Shad:BYTE, \
  75.       CurRow:BYTE
  76.  
  77.   ; load coordinates and attribute into stack vars
  78.   LoadParmB _Top,Top
  79.   dec Top                ; adjust for 0-based BIOS cursor positions
  80.   LoadParmB _Lft,Lft
  81.   dec Lft
  82.   LoadParmB _Lft,Mid      ; mid is position to print middle (lft+1) 
  83.   LoadParmB _Bot,Bot
  84.   dec Bot
  85.   LoadParmB _Rgt,Rgt
  86.   dec Rgt
  87.   LoadParmB _Attr,Attr
  88.   LoadParmB _Shad,Shad
  89.  
  90.   ; calc width
  91.   mov al,Rgt
  92.   sub al,Lft
  93.   dec al
  94.   jnz StoreWid 
  95.   inc al                ; if width is 0, make it 1
  96. StoreWid:
  97.   mov Wid,al
  98.  
  99.   ; init current row
  100.   mov al,Top
  101.   mov CurRow,al
  102.  
  103. TopLine:
  104.   PutChar CurRow,Lft,ULC,Attr,1
  105.   PutChar CurRow,Mid,HOR,Attr,Wid
  106.   PutChar CurRow,Rgt,URC,Attr,1
  107.  
  108. Middle:
  109.   inc CurRow            ; next row
  110.   mov al,Bot            ; at bottom?
  111.   cmp CurRow,al
  112.   jne MidLine           ; no - print middle line  
  113.   jmp BottomLine        ; yes - jump to bottomline
  114.  
  115. MidLine:
  116.   PutChar CurRow,Lft,VER,Attr,1
  117.   PutChar CurRow,Mid,SPC,Attr,Wid
  118.   PutChar CurRow,Rgt,VER,Attr,1
  119.   jmp Middle            ; go to do next line
  120.  
  121. BottomLine:
  122.   PutChar CurRow,Lft,LLC,Attr,1
  123.   PutChar CurRow,Mid,HOR,Attr,Wid
  124.   PutChar CurRow,Rgt,LRC,Attr,1
  125.  
  126.   cmp Shad,0            ; is shadow requested?
  127.   jne Shadow            ; yes - do it
  128.   jmp ByeBye            ; no - bye
  129.  
  130. Shadow:  
  131.   inc Bot               ; shadow offset
  132.   inc Lft     
  133. ShadowBottom:
  134.   inc Lft
  135.   SetCur Bot,Lft
  136.   ShadowChar
  137.   mov al,Lft
  138.   sub al,2
  139.   cmp al,Rgt            ; end of line?
  140.   jl ShadowBottom       ; no - shadow more chars
  141.  
  142.   inc Rgt               ; shadow offset
  143.   mov al,Top
  144.   mov CurRow,al
  145.   mov dl,Rgt            ; save Rgt 
  146. ShadowRight:
  147.   mov Rgt,dl
  148.   inc CurRow
  149.   SetCur CurRow,Rgt     ; shadow rgt
  150.   ShadowChar
  151.   inc Rgt
  152.   SetCur CurRow,Rgt     ; shadow rgt+1
  153.   ShadowChar
  154.   mov al,CurRow
  155.   cmp al,Bot            ; at bottom?
  156.   jl ShadowRight        ; no - shadow more
  157.  
  158. ByeBye:
  159.   ret
  160.  
  161.  
  162. SLBox ENDP
  163.  
  164. END
  165.  
  166.